<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
      <el-form-item label="">
        <el-col :span="6">
          <el-form-item prop="dateType">
            <el-select v-model="formInline.dateType" placeholder="请选择范围">
              <el-option
                v-for="item in consts.AUDIT_DATE_TYPE"
                :label="item.title"
                :key="item.value"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="18">
          <el-form-item prop="time">
            <el-date-picker
              v-model="formInline.time"
              type="datetimerange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd HH:mm:ss"
              :default-time="['00:00:00', '23:59:59']"
              :picker-options="pickerWeekStep">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item>
      <el-form-item label="账户名" prop="username">
        <el-input v-model="formInline.username" placeholder="请输入账号名"  @keyup.enter.native="$emit('on-filter',formInline)"></el-input>
      </el-form-item>
      <!--<el-form-item label="账户类型" prop="userType">-->
      <!--<el-select v-model="formInline.userType" placeholder="请选择账户类型">-->
      <!--<el-option-->
      <!--v-for="item in consts.ACCOUNT_TYPE"-->
      <!--:label="item.title"-->
      <!--:key="item.value"-->
      <!--:value="item.value"-->
      <!--&gt;</el-option>-->
      <!--</el-select>-->
      <!--</el-form-item>-->
      <el-form-item label="操作类型" prop="optType">
        <el-select v-model="formInline.optType" placeholder="请选择操作类型">
          <el-option
            v-for="item in consts.AUDIT_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
            v-if="!item.member&&dataRoleCheck(dataPermissionObj[item.value])||item.value===-1"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="申请人" prop="creator">
        <el-select v-model="formInline.creator" placeholder="请选择申请人">
          <el-option
            v-for="item in auditApplyList"
            :label="item"
            :key="item"
            :value="item"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="一审人" prop="firstApprover">
        <el-select v-model="formInline.firstApprover" placeholder="请选择一审人">
          <el-option
            v-for="item in auditFirList"
            v-if="item"
            :label="item"
            :key="item"
            :value="item"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二审人" prop="secondApprover">
        <el-select v-model="formInline.secondApprover" placeholder="请选择二审人">
          <el-option
            v-for="item in auditSecList"
            v-if="item"
            :label="item"
            :key="item"
            :value="item"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="审核状态" prop="status">
        <el-select v-model="formInline.status" placeholder="请选择审核状态">
          <el-option
            v-for="item in consts.AUDIT_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="$emit('on-filter',formInline)">搜索
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>

  </div>

</template>

<script>
import { getAuditApplierList, getAuditManList, getAuditManSecondList } from '@/services/api/audit';
import { form, grid, pickerOption } from '@/build';

export default {
  name: 'form-filter',
  mixins: [form, grid, pickerOption],
  data() {
    return {
      dataPermissionObj: {
        1: 'memChangeSuperiorAgency',
        2: 'memChangeContact',
        3: 'memResetBankCardName',
        4: 'memWholeLock',
        5: 'memIndirectLock',
        6: 'memUnLock',
        17: 'memLoginLock',
        8: 'memDeleteBank',
        12: 'memClearFlowLimit',
        108: 'memAdjustFlow',
        109: 'memRemoveFlow',
        110: 'memRecoverFlow',
      },
      auditApplyList: [],
      auditFirList: [],
      auditSecList: [],
      formInline: {
        dateType: 0,
        time: [
          moment().format('YYYY-MM-DD 00:00:00'),
          moment().format('YYYY-MM-DD 23:59:59'),
        ],
        userType: 0, // 0-会员，1-代理
        optType: undefined,
        creator: undefined,
        firstApprover: undefined,
        secondApprover: undefined,
        status: undefined,
        username: undefined,
      },
    };
  },
  methods: {
    selfResetForm(formName) {
      this.resetForm(formName);
      this.$emit('on-filter', this.formInline);
    },
  },
  mounted() {
    this.bindGet(getAuditApplierList, 'auditApplyList', {
      sendingData: { status: -1 },
    });
    this.bindGet(getAuditManList, 'auditFirList', {});
    this.bindGet(getAuditManSecondList, 'auditSecList', {});
    this.getAll();
  },
};
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 160px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
